app.controller('RtTaskDetailCtrl', function ($scope, $stateParams, ajax) {

    $scope.tag = $stateParams.tag;
    if ($scope.tag == 0) {
        $scope.url = "app.rent.task()";
    } else if ($scope.tag == 1) {
        $scope.url = "app.rent.restask()";
    }

    $scope.taskId = $stateParams.taskId;
    $scope.shiftId = 0;
    $scope.passengersList = [];
    $scope.task = {};

    $scope.reload = function () {
        ajax.call(new Req.GET({
            resource: 'task/rt/' + $scope.taskId + '/id'
        })).then(function (result) {
            if (result.code && result.code == 200) {
                $scope.task = result.result;
                $scope.shiftId = $scope.task.shift.id;

                ajax.call(new Req.GET({
                    resource: 'task/rt/' + $scope.shiftId + '/passengerlist'
                })).then(function (result) {
                    if (result.code && result.code == 200)
                        $scope.passengersList = result.result;
                }, function () { });
            }
        }, function () { });
    };

    $scope.reload();
});